<include file='Admin/Tpl/Public/nav.html' />
<style>.text{display:none}</style>
<div class="page-content">
    <div class="container-fluid">
        <br/>
        <ol class="breadcrumb default square rsaquo sm">
            <li><a href="index.html"><i class="fa fa-home"></i></a></li>
            <li><a href="#fakelink">Teamin</a></li>
            <li class="active"> 问题管理 </li>
        </ol>
        <!--start-->
        <div class="row">
            <div class="col-sm-4 left">
                <div class="the-box">
                    <div class="table-responsive div1 div_search">
                    <form action="__URL__/add_question_act" method="post" enctype="multipart/form-data">
                    	<input type="hidden" value="<PHP>echo $_GET['questionnaire_id']</PHP>" name="questionnaire_id" />
                        <div class="form-group">
                            <label>问题名称</label>
                            <input type="text" class="form-control" name="question_title">
                        </div>
                        
                        <div class="form-group">
                        <label>类型</label>
                            <select class="form-control" tabindex="2" name="question_type" onchange="show_text()">
                                <option value="3">填空</option>
                                <option value="1">单选</option>
                                <option value="2">多选</option>
                                <option value="4">单选+其他</option>
                            </select>
                        </div>
                        
                        <div class="form-group text">
                            <input class="btn btn-success" type="button" onclick="add_new_opt()" value="增加一个选项" />
                        </div>
                        
                        <div class="form-group text">
                            <label>A</label>
                            <input type="text" class="form-control" name="answer[]">
                        </div>
                        
                        <div class="form-group text">
                            <label>B</label>
                            <input type="text" class="form-control" name="answer[]">
                        </div>
                        
                        <div class="add_new_option"></div>
                        
                        <div class="form-group">
                            <input class="btn btn-primary" id="submit" type="submit" value="提交" />
                        </div>
                    </form>
                    </div>
                    <div class="table-responsive" id="hl"></div>
                 </div>
            </div>
            
			<div class="col-sm-8 right">
                <div class="the-box">
                    <div class="table-responsive div1 div_search">
                        <form action="__URL__/del_question_act/question_id" method="post">
                            <volist name="re" id="value">
                                <details>
                                    <summary style="font-size:large">
                                        第{$value.num}题&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        问题:【{$value.question_title}】&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        题型:【<if condition="$value.question_type eq 1" >单选
                                               <elseif condition="$value.question_type eq 2 "/>多选
                                                <elseif condition="$value.question_type eq 3 "/>填空
                                                <else />单选+其他
                                                </if>】&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        答题人数:{$value.audience_num}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a href='javascript:void(0)' onclick='delAct({$value.question_id})' title='Delete'>删除</a>
                                    </summary>
                                    <div class="form-control" style="height:auto; overflow:hidden;">
                                        <section>
                                            <table class="table table-th-block table-hover">
                                                <tr>
                                                    <td style="text-align:center">选项</td>
                                                    <td style="text-align:center">答案</td>
                                                    <td style="text-align:center">参选人数(人)</td>
                                                    <td style="text-align:center">所占比例(%)</td>
                                                </tr>
                                                <volist name="rz" id="val">
                                                <?php 
                                                    if($val['question_id'] == $value['question_id']){
                                                ?>
                                                    <tr>
                                                        <td style="text-align:center">{$val.opt}</td>
                                                        <td style="text-align:center">what</td>
                                                        <td style="text-align:center">{$val.num}</td>
                                                        <td style="text-align:center">{$val.percent}</td>
                                                    </tr>
                                                <?php 
                                                    }
                                                ?> 
                                                   
                                                </volist>
                                                <?php 
                                                    if($value['question_type'] == '4'){
                                                ?> 
                                                 <tr>
                                                        <td style="text-align:center">other</td>
                                                        <td style="text-align:center">what</td>
                                                        <td style="text-align:center">0</td>
                                                        <td style="text-align:center">0</td>
                                                    </tr>
                                                <?php
                                                    }
                                                ?>
                                            </table>
                                        </section>
                                    </div>
                                </details>
                        </volist>
                        </form>
                        <ul class="pagination success">{$rs.show}</ul>
                    </div>
                    <div class="table-responsive" id="hl"></div>
                 </div>
            </div>
        </div>
        <!--end-->
        
    </div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
function show_text(){
	if($('[name="question_type"]').val() != 3){
		$('.text').each(function(index, element) {
            $(this).show();
        });
	}else{
		$('.text').each(function(index, element) {
            $(this).hide();
        });
	}
}
//字符转ascii码：用charCodeAt();
//ascii码砖字符：用fromCharCode();
var opt='C';
var choice='';
function add_new_opt(){	
	choice = '<div class="form-group">';
	choice+= '<label>'+opt+'</label>';
	choice+= '<input type="text" class="form-control" name="answer[]">';
	choice+= '</div>';
			
	if($(".add_new_option").html()=='')
		$('.add_new_option').html(choice);
	else
		$('.add_new_option').html($(".add_new_option").html()+choice);
				
	opt = String.fromCharCode(opt.charCodeAt() + 1);
}

function delAct(a){
    if(confirm('确认删除?')){
        $.get(
            '__URL__/del_question?question_id='+a,
            function(){ window.location='__SELF__';},'json');
    }
}

</script>
